//
//  ECMemberFiltrateTableViewCell.m
//  ECERP.CRM
//
//  Created by 刘思麟 on 2018/11/4.
//  Copyright © 2018 Mac. All rights reserved.
//

#import "ECMemberFiltrateTableViewCell.h"

@interface ECMemberFiltrateTableViewCell()

@property (nonatomic,strong) UIImageView * imgV;

@end

@implementation ECMemberFiltrateTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)prepareForReuse {
    [super prepareForReuse];
    self.titleLB.text = nil;
    self.detailLB.text = nil;
}

- (void)setupUI {
    WS(weakSelf, self);
    self.titleLB = [UILabel new];
    self.titleLB.textColor = ECCOLOR(0x333333);
    self.titleLB.font = ECFONT(16);
    
    self.imgV = [UIImageView new];
    self.imgV.image = [UIImage imageNamed:@"more_member"];
    [self.contentView addSubview:self.imgV];
    [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.contentView);
        make.right.mas_equalTo(weakSelf.contentView).mas_offset(-10);
    }];
    
    self.detailLB = [UILabel new];
    self.detailLB.textColor = ECCOLOR(0xCCCCCC);
    self.detailLB.font = ECFONT(13);
    [self.contentView addSubview:self.detailLB];
    [self.detailLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.contentView);
        make.right.mas_equalTo(weakSelf.imgV.mas_left).mas_offset(-5);
    }];
    
    [self.contentView addSubview:self.titleLB];
    [self.titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.contentView);
        make.left.mas_equalTo(weakSelf.contentView).mas_offset(16);
        make.right.mas_lessThanOrEqualTo(weakSelf.detailLB.mas_left).mas_offset(10);
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    if (selected) {
        self.detailLB.textColor = ECCOLOR(0x41D95A);
        self.imgV.image = [[UIImage imageNamed:@"more_member"] imageByTintColor:ECCOLOR(0x41D95A)];
    }else{
        self.detailLB.textColor = ECCOLOR(0xCCCCCC);
        self.imgV.image = [UIImage imageNamed:@"more_member"];
    }
}

@end
